package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;

public class DADD extends Instruction {
	public  void readindex(ByteBuffer reader) {
		//no need to read
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
        Object temp2hi=stack[top-1];
        Object temp2lo=stack[top-2];
        Object temp1hi=stack[top-3];
        Object temp1lo=stack[top-4];
        top=top-4;
    	int temp1high=(int)temp1hi;
    	int temp1low=(int)temp1lo;
    	int temp2high=(int)temp2hi;
    	int temp2low=(int)temp2lo;
    	long temp1=(((long) temp1high) << 32) | ((long) temp1low & 0x0ffffffffL);
    	long temp2=(((long) temp2high) << 32) | ((long) temp2low & 0x0ffffffffL);
    	double value1=Double.longBitsToDouble(temp1);
    	double value2=Double.longBitsToDouble(temp2);
    	double value=value1+value2;
    	long temp=Double.doubleToLongBits(value);
    	stack[top]=(int)temp;
    	stack[top+1]=(int)(temp>>32);
    	top=top+2;
    	frame.setManagestack(stack);
    	frame.setStacktop(top);
	}
}
